package com.ganbo.thread.join;

/**
 * Created by gan on 2020/5/20 22:00.
 */
public class JoinDemo extends Thread {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "开始执行。。。");
//        int secondValue = (int) (Math.random() * 1000);
        int secondValue = 5000;
        System.out.println("secondValue===>" + secondValue);
        try {
            Thread.sleep(secondValue);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(Thread.currentThread().getName() + "执行完毕");
    }

    public static void main(String[] args) throws InterruptedException {
        JoinDemo joinDemo = new JoinDemo();
        joinDemo.start();

        joinDemo.join(2000);
        System.out.println(Thread.currentThread().getName() + "执行完毕...");
    }
}
